package com.axxc.jpa.pattendegign.flyweight;

import com.axxc.jpa.pattendegign.commons.C;

/**
 * @ClassName A
 * @Description //TODO 模拟享元模式
 * @author xxc
 * @data 2018年9月13日下午10:11:15
 * @see {@link http://gitee.com/biuabiu/ }
 */
public class A implements C {

	public A(String name) {
		super();
		this.name = name;
	}

	private String name;

	public C getA() {
		C c = Flyweight.cMapChche.get("a");
		if (c == null) {
			Flyweight.cMapChche.put("a", this);
			System.out.println("第一次构建A");
			return this;
		} else {
			System.out.println("缓存获取A");
			return c;
		}
	}

	private static final long serialVersionUID = 1L;

	@Override
	public void show() {
		System.out.println("A");
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
